﻿package com.obj {
	import com.custardbelly.as3flobile.controls.button.Button;
	import com.custardbelly.as3flobile.controls.button.ToggleButton;
	import com.custardbelly.as3flobile.controls.label.Label;
	import com.custardbelly.as3flobile.controls.list.ScrollList;
	import com.custardbelly.as3flobile.controls.list.layout.IScrollListHorizontalLayout;
	import com.custardbelly.as3flobile.controls.list.layout.IScrollListVerticalLayout;
	import com.custardbelly.as3flobile.controls.list.layout.ScrollListHorizontalLayout;
	import com.custardbelly.as3flobile.controls.list.layout.ScrollListVerticalLayout;
	import flash.display.Sprite;
	import org.osflash.signals.events.GenericEvent;
	import com.selectPrinter;
	import flash.printing.PrintJob;
	import com.custardbelly.as3flobile.skin.ScrollListSkin;
	import flash.display.Graphics;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import mx.utils.ObjectUtil;
	
	public class ListPrinterSelect extends MovieClip {
		protected var _dataProvider:Array;
		protected var _list:ScrollList;
		protected var _verticalLayout:IScrollListVerticalLayout;
		protected var _horizontalLayout:IScrollListHorizontalLayout;
		
		protected var _isVariableSize:Boolean;
		protected var _layoutState:uint;
		
		private static const STATE_VERT:uint = 0;
		private static const STATE_HORIZ:uint = 1;
		
		
		

		public function ListPrinterSelect(MainStage:MovieClip)  {
			// constructor code
			
			btnSelect.addEventListener(MouseEvent.MOUSE_UP,function(e:MouseEvent){
										   //trace(ObjectUtil.toString(_list.selectedItem));
										   //printerSelect = _list.selectedItem['label'];
										   MainStage.printerSelect = _list.selectedItem['label'];
										   MainStage.testPrint();
										   });
			
			_horizontalLayout = new ScrollListHorizontalLayout();
			_horizontalLayout.itemWidth = 100;
			_horizontalLayout.useVariableWidth = false;
			_horizontalLayout.itemWidth = 200;
			
			_layoutState = ListPrinterSelect.STATE_HORIZ;
			
			_list = new ScrollList();

			

			
			//_list.skin = _skin;
			_list.width = 800;
			_list.height = 300;
			_list.y = 90;
			
			
			
			
			
			trace(_list.backgroundDisplay);
			
			
			
			_list.layout = _horizontalLayout
			addChild( _list );
			_dataProvider = getList( 20 );
			_list.dataProvider = _dataProvider;
			

			

		}
		
		protected function closeDialog():void{
			
			
			}

		
		protected function getList( length:int, front:String = "Item Renderer " ):Array
		{
			var arr:Array = new Array( length );
			var printerList:Vector.<String> = PrintJob.printers;
			var arrPrinters:Array =new Array();
			var _icon:PRINTER_ITEM = new PRINTER_ITEM();
			
			/*var _obj:Object = new Object();
				_obj.test="TEST";
				_obj.icon = _icon;*/
				
			
			
			for( var i:int = 0; i < printerList.length; i++ )
			{
				
				
				arr[i] = {label:printerList[i].toString()};
			}
			return arr;
		}

	}
	
}
